#ifndef HEAD_H
#define HEAD_H

#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>       
#include<netinet/in.h>
#include<pthread.h>
#include<sys/epoll.h>
#include<string.h>
#include<unistd.h>
#include<signal.h>
#include "./queue.h"

#define ERR_LOG(msg) do { \
    printf("在文件 %s 的函数 %s 的第 %d 行\n", __FILE__, __func__, __LINE__); \
    perror(msg); \
    exit(EXIT_FAILURE); \
} while(0)

typedef struct status_s{

    pthread_t *thread_ids;
    int thread_num;
    queue_t queue;
    pthread_mutex_t mutex;
    pthread_cond_t cond;

}status_t;


int init_status(status_t*status,int thread_num);

int init_threadpool(status_t*status);

int init_socket(int *socked,char*ip ,char*port);

int add_epoll(int epoll_fd, int sock_fd); 

void* thread_main(void* p);

int do_worker(int fd); 

#endif 